#include "ResourceManager.h"

namespace glow
{
	using namespace std;
	
	ResourceManager *ResourceManager::_inst = NULL;
	
	ResourceManager::ResourceManager()
	{
	}
	
	ResourceManager::~ResourceManager()
	{
	}
	
	void ResourceManager::add(IResource *resource)
	{
		if(resource)
			_allR.push_back(resource);
	}
    
    void ResourceManager::remove(string filename)
    {
		for (std::vector<IResource*>::iterator it = _allR.begin(); it != _allR.end(); )
		{
			if ((*it)->getName() == filename)
				it = _allR.erase(it);
			else
				++it;
		}
	}
    
    ResourceManager *ResourceManager::getInstance()
    {
		if(!_inst)
			_inst = new ResourceManager();
		return _inst;
	}
	
	void ResourceManager::destroy()
	{
		if(_inst)
			delete _inst;
		_inst = NULL;
	}
}

     
